﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Hopscotch.Presentation.Common.Converters
{
    [ValueConversion(typeof(string), typeof(Visibility))]
    public class StringToVisibiltyConverter : IValueConverter
    {
        /// <summary>
        /// The visibility value to convert to if source value is empty
        /// </summary>
        public Visibility EmptyValue { get; set; }

        /// <summary>
        /// The visibility value to convert to if the source string is not null or empty
        /// </summary>
        public Visibility TextValue { get; set; }

        public StringToVisibiltyConverter()
        {
            EmptyValue = Visibility.Collapsed;
            TextValue = Visibility.Visible;
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (String.IsNullOrEmpty((string)value))
            {
                return EmptyValue;
            }

            return TextValue;

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
